

#ifndef IQW_MODULE_ENCODER_H__
#define IQW_MODULE_ENCODER_H__


#include <stdint.h> 
#include <stdbool.h> 

#include "kb.h"
#include "custom_event.h"
typedef enum encoder_stete_e{
STATE_IDLE=0,
	
STATE_START_A,
STATE_MIDDLE_A,
STATE_READY_A,

STATE_START_B,
STATE_MIDDLE_B,
STATE_READY_B,
}encoder_stete;

typedef struct st_encoder{
uint8_t a_pin;
uint8_t b_pin;

uint16_t a_count;
uint16_t b_count;

uint32_t timetick;
uint32_t last_timetick;

custom_evt_handle_t  handler;
void  *encoder_timer;

uint8_t  is_timer_started;
encoder_stete state;
}encoder_t;

void em_encoder_init(void); 

void em_encoder_start(void);

void em_encoder_stop(void); 

void em_encoder_register_callback( custom_evt_handle_t cb ); 

bool em_encoder_system_wakeup_dlps_check(void); 

void em_encoder_enter_dlps(void);

void em_encoder_exit_dlps(void); 

void xapp_encoder_init(void);

#endif 

